<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
</head>

<body>

    <p>创建和使用对象方法。</p>
    <p>对象方法作为一个函数定义存储在对象属性中。</p>
    <p id="demo"></p>

    <p id = "demo2">创建一个对象</p>
    <p id = "demo3">创建一个对象</p>
    <script>
        var person = {
            firstName: "John",
            lastName: "Doe",
            id: 5566,
            fullName: function () {
                return this.firstName + " " + this.lastName;
            }
        };
        document.getElementById("demo").innerHTML = person.fullName();

        //创建JavaScript对象
        var person = {firstName:"hanjiale", lastName:"guoyinx", age:20, eyeColor:"blue"};
        var person = {
                        firstName : "John",
                        lastName  : "Doe",
                        age       : 50,
                        eyeColor  : "blue"
                    };
        document.getElementById("demo2").innerHTML = person.firstName + "现在" + person.age + "了";
        document.getElementById("demo3").innerHTML = person["firstName"] + "现在" + person["age"] + "了";
    </script>

</body>

</html>